package com.aspose.cells;

import java.util.ArrayList;
import java.util.List;

final class zir {
   static void a(zn var0, zip var1, boolean var2) throws Exception {
      if (var1.a().u() && !var1.a().B().D()) {
         zif var3 = var1.a();
         int var4 = var3.ap().j();
         if (var3.i().d().g() && var3.ap().j() != 4) {
            var3.ap().b(4);
         }

         int var5 = var3.M();
         boolean var6 = var3.e().p();
         int var7 = var1.a.c();
         int var8 = var1.a.d();
         int var9 = var1.a.e();
         com.aspose.cells.b.a.b.zs var10 = var1.q();
         int var11 = var10.c() + var1.r();
         zalc.a(var0, var1.a().x());
         ArrayList var13 = var1.o().a(true, var2);
         com.aspose.cells.b.a.b.zp var14 = new com.aspose.cells.b.a.b.zp(var7, var8, var9, var11);
         com.aspose.cells.b.a.b.zp var15 = new com.aspose.cells.b.a.b.zp(var7 - var10.b(), var8 + var1.r(), var9 + var10.b(), var10.c());
         if (var1.i()) {
            zama.a(var0, var14, var1.d());
            zama.a(var0, var15, var1.d());
         }

         float var16;
         float var17;
         int var20;
         if (var1.h()) {
            var17 = (float)var15.h();

            for(var20 = 0; var20 < var13.size() - 1; ++var20) {
               zala var21 = (zala)var13.get(var20);
               zbcp var22 = var21.i();
               var16 = (float)var15.g();
               var17 += (float)var22.a.c();
               float var18 = (float)var15.i();
               zama.a(var0, var16, var17, var18, var17, var1.d());
            }
         }

         var20 = var3.z().h();
         com.aspose.cells.b.a.b.zg var47 = var1.b();
         zafs var48 = var3.z().a();
         ArrayList var23 = var3.z().c();
         com.aspose.cells.b.a.b.zu var24 = new com.aspose.cells.b.a.b.zu(var1.c());

         try {
            float var25 = (float)var9 / (float)var20;
            int var26 = 0;

            label245:
            while(true) {
               float var19;
               if (var26 >= var20) {
                  ArrayList[] var49 = var3.z().e();
                  if (var49 != null && var49.length > 0 && var3.z().c().size() > 0) {
                     zbo var50 = var3.e();
                     float var52 = (float)var1.j();
                     float var56 = (float)(var49.length + 1) * var52;
                     ArrayList var57 = var49[0];
                     zfo var31 = (zfo)var57.get(0);
                     String var32 = zpv.a(var3.al(), var31.a(), var31.c(), var31.b());
                     zbsp.a(var50.c().ap(), var32, 0, var47, (com.aspose.cells.b.a.b.zs)(new com.aspose.cells.b.a.b.zs(var9, var1.r())), 1, 1);
                     float var34 = (float)var8;
                     boolean var35 = false;
                     float var36 = (float)var15.h();
                     float var37 = 0.0F;
                     if (!var6) {
                        var37 = (float)var14.g();
                     } else {
                        var37 = (float)var14.i();
                     }

                     a(var0, var49, var37, var36, var52, var35, var50, (double)var25, var1, 1, var34, var14, false);
                  }

                  float var51 = (float)var15.h();
                  int var54 = 0;

                  while(true) {
                     if (var54 >= var13.size()) {
                        break label245;
                     }

                     zala var58 = (zala)var13.get(var54);
                     zbcp var59 = var58.i();
                     com.aspose.cells.b.a.b.zo var60 = new com.aspose.cells.b.a.b.zo((float)(var15.g() + var1.k()), var51 + (float)var1.j());
                     float var61 = (float)var59.a.b();
                     float var33 = (float)var59.a.c();
                     if (var1.f()) {
                        com.aspose.cells.b.a.b.zq var62 = new com.aspose.cells.b.a.b.zq((float)(var15.g() + var1.l()), var51 + (float)var1.j(), (float)var1.m(), var1.p());
                        a(var0, var1, var62, var59);
                        var60.a(var60.d() + (float)(var1.l() + var1.m()));
                        var61 -= (float)(var1.l() + var1.m());
                     }

                     String var63 = var59.i();
                     com.aspose.cells.b.a.b.zq var64 = new com.aspose.cells.b.a.b.zq(var60.d(), var60.e(), var61, var33);
                     com.aspose.cells.b.a.b.zv var65 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
                     var0.a(var63, var47, var24, (com.aspose.cells.b.a.b.zq)var64, var65);

                     for(int var66 = 0; var66 < var59.D().getCount(); ++var66) {
                        if (var1.g() && var66 < var59.D().getCount() - 1) {
                           var16 = (float)var7 + (float)(var66 + 1) * var25;
                           var19 = var51 + (float)var59.a.c();
                           zama.a(var0, var16, var51, var16, var19, var1.d());
                        }

                        int var38 = var66;
                        if (var6) {
                           var38 = var59.D().getCount() - var66 - 1;
                        }

                        zjd var39 = var59.D().b(var38);
                        if (!var39.a()) {
                           String var40 = var39.z();
                           boolean var41 = var39.A();
                           var63 = zpv.a(var3.al(), var39.v(), var40, var41);
                           com.aspose.cells.b.a.b.zq var42 = new com.aspose.cells.b.a.b.zq((float)var7 + (float)var66 * var25, var51 + (float)var1.j(), var25, (float)(var59.a.c() - 2 * var1.j()));
                           com.aspose.cells.b.a.b.zv var43 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
                           var43.a(1);
                           var43.c(0);
                           var0.a(var63, var47, var24, (com.aspose.cells.b.a.b.zq)var42, var43);
                        }
                     }

                     var51 += (float)var59.a.c();
                     ++var54;
                  }
               }

               if (var1.g()) {
                  var16 = (float)var7 + var25 * (float)var26;
                  var17 = (float)var14.h();
                  var19 = var17 + (float)var1.s();
                  zama.a(var0, var16, var17, var16, var19, var1.d());
               }

               int var27 = var26;
               if (var6) {
                  var27 = var20 - var26 - 1;
               }

               String var28 = "";
               if (var27 < var48.getCount() && var3.z().e() == null) {
                  zafr var53 = var48.a(var27);
                  var28 = zpv.a(var3.al(), var53.a(), var53.c(), var53.b());
               } else if (var27 < var23.size()) {
                  zfo var29 = (zfo)var23.get(var27);
                  var28 = zpv.a(var3.al(), var29.a(), var29.c(), var29.b());
               }

               com.aspose.cells.b.a.b.zq var55 = new com.aspose.cells.b.a.b.zq((float)var7 + (float)var26 * var25, (float)(var8 + var1.j()), var25, (float)(var1.s() - var1.j()));
               com.aspose.cells.b.a.b.zv var30 = new com.aspose.cells.b.a.b.zv(com.aspose.cells.b.a.b.zv.c());
               var30.c(0);
               var30.a(1);
               var0.a(var28, var47, var24, (com.aspose.cells.b.a.b.zq)var55, var30);
               ++var26;
            }
         } finally {
            if (var24 != null) {
               var24.f();
            }

         }

         if (var3.i().d().g() && var3.ap().j() != var4) {
            var3.ap().b(var4);
         }

      }
   }

   static void a(zn var0, zip var1, com.aspose.cells.b.a.b.zq var2, zbcp var3) {
      float var4;
      if (var3.m() != 12 && var3.m() != 13) {
         float var15;
         if (var3.aj()) {
            if (var3.z().e()) {
               zama.a(var0, var2.f(), var2.g() + var2.i() / 2.0F, var2.f() + var2.h(), var2.g() + var2.i() / 2.0F, var3.z());
            }

            if (var3.B().d() != 1) {
               var4 = var2.f() + var2.h() / 2.0F;
               var15 = var2.g() + var2.i() / 2.0F;
               float var16;
               if (var3.B().c() == 0) {
                  var16 = var2.i() * zalc.b;
               } else {
                  int var17 = (int)((float)(var3.h().c() * 72) / var0.g());
                  if ((float)var17 <= var2.i() * zalc.b) {
                     var16 = (float)var3.B().c();
                  } else {
                     float var8 = (float)(var17 / var3.v().i().m());
                     if (var8 > 1.0F) {
                        var8 = 1.0F;
                     }

                     var16 = var2.i() * zalc.b * (1.0F + var8);
                     var16 = (float)((int)((double)(var16 * var0.g() / 72.0F) + 0.5D));
                  }
               }

               zalc.a(var0, var4, var15, var3.B(), var16, true);
            }
         } else {
            var4 = var2.h();
            var15 = (float)var1.n();
            com.aspose.cells.b.a.b.zq var18 = new com.aspose.cells.b.a.b.zq(var2.f(), var2.g() + var2.i() / 2.0F - var15 / 2.0F, var4, var15);
            zax.a(var0, var18, var3.A());
            zama.a(var0, var18, var3.z());
         }
      } else {
         var4 = (float)var1.n();
         com.aspose.cells.b.a.b.zq var5 = new com.aspose.cells.b.a.b.zq(var2.f(), var2.g() + (var2.i() - var4) / 2.0F, var4, var4);
         com.aspose.cells.b.a.b.zc var6 = zax.a(var3.A(), var5);

         try {
            var0.a(var6, var5);
         } finally {
            if (var6 != null) {
               var6.f();
            }

         }

         com.aspose.cells.b.a.b.zm var7 = zama.a(var3.z());

         try {
            var0.a(var7, var5);
         } finally {
            if (var7 != null) {
               var7.r();
            }

         }
      }

   }

   private static void a(zn var0, ArrayList[] var1, float var2, float var3, float var4, boolean var5, zbo var6, double var7, zip var9, int var10, float var11, com.aspose.cells.b.a.b.zp var12, boolean var13) {
      zif var14 = var9.a();
      byte var15 = 0;
      float var16 = var3;
      com.aspose.cells.b.a.b.zt var17 = new com.aspose.cells.b.a.b.zt((float)var7, (float)var12.f() / 2.0F);

      for(int var18 = 0; var18 < var1.length; ++var18) {
         ArrayList var19 = var1[var18];
         com.aspose.cells.b.a.b.zs var20 = a(var0, var19, var15, var9, var17);
         float var21 = var2;

         for(int var22 = 0; var22 < var19.size(); ++var22) {
            zfo var23 = (zfo)var19.get(var22);
            String var24 = zpv.a(var14.al(), var23.a(), var23.c(), var23.b());
            int var25 = zbq.a(var23);
            float var26 = (float)((double)var25 * var7);
            float var27;
            if (!var6.p()) {
               var27 = var21 + var26 / 2.0F - (float)(var20.b() / 2);
            } else {
               var27 = var21 - var26 / 2.0F - (float)(var20.b() / 2);
            }

            float var28 = var5 ? var16 : var16 - (float)var20.c();
            com.aspose.cells.b.a.b.zq var29 = new com.aspose.cells.b.a.b.zq(var27, var28, (float)var20.b(), (float)var20.c());
            zbq.a(var0, com.aspose.cells.b.a.b.zp.a(var29), var24, var15, var9.b(), var9.c(), 1, var10);
            if (var6.c().l().g()) {
               zama.a(var0, var21, var11, var21, var16, var9.d());
            }

            if (var6.c().l().g()) {
               float var30 = var5 ? var16 + var4 + (float)var20.c() : var16 - (var4 + (float)var20.c());
               a(var0, var23.d(), var21, var11, var30, var5, var6, var7);
            }

            if (!var6.p()) {
               var21 += var26;
            } else {
               var21 -= var26;
            }
         }

         if (var6.c().l().g()) {
            zama.a(var0, var21, var11, var21, var16, var9.d());
         }

         if (var5) {
            var16 += var4 + (float)var20.c();
         } else {
            var16 -= var4 + (float)var20.c();
         }
      }

   }

   static com.aspose.cells.b.a.b.zs a(zn var0, List var1, int var2, zip var3, com.aspose.cells.b.a.b.zt var4) {
      int var5 = 0;
      int var6 = 0;

      for(int var7 = 0; var7 < var1.size(); ++var7) {
         zfo var8 = (zfo)var1.get(var7);
         String var9 = zpv.a(var3.a().al(), var8.a(), var8.c(), var8.b());
         com.aspose.cells.b.a.b.zs var10 = zbsp.a(var0, var9, var2, var3.b(), (com.aspose.cells.b.a.b.zt)var4, 1, 1);
         if (var10.b() > var5) {
            var5 = var10.b();
         }

         if (var10.c() > var6) {
            var6 = var10.c();
         }
      }

      return new com.aspose.cells.b.a.b.zs(var5, var6);
   }

   private static void a(zn var0, zafs var1, float var2, float var3, float var4, boolean var5, zbo var6, double var7) {
      float var9 = var2;

      for(int var10 = 0; var10 < var1.getCount(); ++var10) {
         zfo var11 = (zfo)var1.a(var10);
         int var12 = zbq.a(var11);
         float var13 = (float)((double)var12 * var7);
         if (!var6.p()) {
            var9 += var13;
         } else {
            var9 -= var13;
         }

         zama.a(var0, var9, var3, var9, var4, var6.c().k().d());
      }

   }

   static com.aspose.cells.b.a.b.zs a(zn var0, zip var1, com.aspose.cells.b.a.b.zp var2) {
      if (!var1.a().u()) {
         return new com.aspose.cells.b.a.b.zs(0, 0);
      } else {
         zif var3 = var1.a();
         com.aspose.cells.b.a.b.zt var4 = new com.aspose.cells.b.a.b.zt((float)(var2.e() / 3), (float)(var2.f() / 3));
         int var5 = var1.m();
         if (var1.f()) {
            var4.a(var4.b() - (float)(var1.l() + var5));
         }

         com.aspose.cells.b.a.b.zt var6 = new com.aspose.cells.b.a.b.zt(0.0F, 0.0F);
         zaky var8 = var1.o();

         for(int var9 = 0; var9 < var8.getCount(); ++var9) {
            zala var10 = var8.c(var9);
            zbcp var11 = var10.i();
            String var12 = var11.i();
            com.aspose.cells.b.a.b.zt var7 = zbuk.a(var0, var12, var1.b(), var4);
            var7.a(var7.b() + (float)(2 * var1.k()));
            var7.b(var7.c() + (float)(2 * var1.j()));
            if (var1.f()) {
               var7.a(var7.b() + (float)(var1.l() + var5));
            }

            var11.a = new com.aspose.cells.b.a.b.zs(zbuk.a((double)var7.b()), zbuk.a((double)var7.c()));
            if (var6.b() < var7.b()) {
               var6.a(var7.b());
            }

            var6.b(var6.c() + var7.c());
         }

         return new com.aspose.cells.b.a.b.zs(zbuk.a((double)var6.b()), zbuk.a((double)var6.c()));
      }
   }

   static int b(zn var0, zip var1, com.aspose.cells.b.a.b.zp var2) {
      com.aspose.cells.b.a.b.zs var3 = zbsp.a(var0, "a", var1.b());
      byte var4 = 0;
      com.aspose.cells.b.a.b.zg var5 = var1.b();
      zif var6 = var1.a();
      ArrayList var7 = var6.z().c();
      ArrayList[] var8 = var6.z().e();
      float var9 = (float)var2.e() / (float)var7.size();
      com.aspose.cells.b.a.b.zt var10 = new com.aspose.cells.b.a.b.zt(var9, (float)var2.f() / 2.0F);
      com.aspose.cells.b.a.b.zs var11 = new com.aspose.cells.b.a.b.zs(0, 0);
      int var12;
      com.aspose.cells.b.a.b.zs var15;
      if (var7.size() > 0) {
         for(var12 = 0; var12 < var7.size(); ++var12) {
            zfo var13 = (zfo)var7.get(var12);
            String var14 = zpv.a(var1.a().al(), var13.a(), var13.c(), var13.b());
            var15 = zbsp.a(var0, var14, 0, var5, (com.aspose.cells.b.a.b.zt)var10, 1, 1);
            if (var15.b() > var11.b()) {
               var11.a(var15.b());
            }

            if (var15.c() > var11.c()) {
               var11.b(var15.c());
            }
         }
      } else {
         var11 = zbsp.a(var0, "123", 0, var5, (com.aspose.cells.b.a.b.zt)var10, 1, 1);
      }

      if (var11.c() > var3.c() * 2) {
         var11.b(var3.c() * 2);
      }

      var1.b(var11.c() + var1.j() * 2);
      int var16 = var4 + var1.s();
      var12 = 0;
      if (var8 != null && var8.length > 0 && var7.size() > 0) {
         var16 += var1.j() * var8.length;

         for(int var17 = 0; var17 < var8.length; ++var17) {
            ArrayList var18 = var8[var17];
            var15 = a(var0, var18, 0, var1, var10);
            var12 += var15.c();
         }
      }

      var16 += var12;
      return var16;
   }
}
